import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false;
//引入动画样式
import "animate.css";

// 重置样式
import "@/assets/css/reset.css";
//全局样式  自定义图标
import "@/assets/css/global.css";
//mock模拟数据
import "/mock";
//按需加载element-ui组件
import "@/plugin/element";
import "element-ui/lib/theme-chalk/index.css";
//按需加载echarts
import "@/plugin/echarts";
//引入路由守卫
import "./promission";
//引入iconfont
import "@/assets/icon/iconfont.css";
//全局组件
import Header from "@/components/header";
Vue.component("publicHeader", Header);
import elliTip from "@/components/globalCom/elliTip.vue";
Vue.component("elliTip", elliTip);
import kkCopy from '@/components/globalCom/copy'
Vue.component("kkCopy", kkCopy);
//codemirror
// import VueCodemirror from "vue-codemirror";
// import "codemirror/lib/codemirror.css";
// Vue.use(VueCodemirror);

//自定义指令
import "./directive";

//所有的接口
import route from "@/Api/route";
import login from "@/Api/login";
import expireLoginApi from "@/Api/expireLogin";
//把所有的接口挂载在vue原型上
Vue.prototype.$http = { ...route, ...login, ...expireLoginApi };
//挂在一个新的alert
// import alert from '@/components/window/alert.vue'
// Vue.prototype.$alert = alert
//重写alert方法,用来进行弹窗提示
window._alert = window.alert;
window.alert = (value, options) => {
  console.log(value, options);
  Vue.prototype.$alert(value, "自定义", options);
};

//vue   安装插件实现全局弹窗
import diyalert from "@/components/window/alert.js";
Vue.use(diyalert, { color: "pink" });
// 登录过期弹窗
import expireLogin from "@/components/expireLogin/login.js";
Vue.use(expireLogin);
window.login = Vue.prototype.$login;
import focus from "@/components/window/focus.js";
Vue.use(focus);

//实现中英文切换
import VueI18n from "vue-i18n";
Vue.use(VueI18n);

const i18n = new VueI18n({
  locale: "zh-CN", // 设置默认语言为中文
  messages: {
    "zh-CN": require("./assets/lang/zh.js"), // 中文语言包
    "en-US": require("./assets/lang/en.js"), // 英文语言包
  },
});
import websocket from "./utils/websocket.js";
Vue.prototype.$Ws = websocket;
HTMLElement.prototype.setStyle = function (obj) {
  for (let key in obj) {
    this.style[key] = obj[key];
  }
};

const a = require.context('/src/ceshiCom' , false , /\.vue$/)
console.log(a.keys());
console.log(a);
a.keys().forEach(item=>{
  console.log(a(item));
  Vue.component(item.replace(/^\.\// , '').replace(/\.vue$/ , '') , a(item).default)
})
new Vue({
  router,
  store,
  render: (h) => h(App),
  i18n,
}).$mount("#app");

//配置项
import "./config.js";
